#include <algorithm>
#include "MidpointFilter.h"

void
MidpointFilter::help(std::string &buf) const
{
    buf.append("中点滤波器;适合处理随即分布的噪声,如高斯噪声,均匀分布噪声\n");
    Filter::help(buf);
    return ;
}

double
MidpointFilter::operOnNeigh(const cv::Mat &neigh)
{

    double max = *std::max_element(neigh.begin<uchar>(),neigh.end<uchar>());
    double min = *std::min_element(neigh.begin<uchar>(),neigh.end<uchar>());
    return (max + min) / 2;
}

NOISE_ALGO_REGISTER("MidpointFilter",MidpointFilter);


